package org.jeecg.modules.golf.question.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.golf.plan.client.MyPlanAnalysisDTO;
import org.jeecg.modules.golf.plan.client.MyPlanAnalysisQueryDTO;
import org.jeecg.modules.golf.question.client.QuestionTagAnalysisDTO;
import org.jeecg.modules.golf.question.client.QuestionTypeAnalysisDTO;
import org.jeecg.modules.golf.question.client.StatisticsQuestionStatusDTO;
import org.jeecg.modules.golf.question.client.TrainAnalysisDTO;
import org.jeecg.modules.golf.question.client.qto.QuestionQueryPageDTO;
import org.jeecg.modules.golf.question.client.qto.StatisticsQuestionAnalysisQueryDTO;
import org.jeecg.modules.golf.question.service.IMyQuestionPlanService;
import org.jeecg.modules.golf.question.service.IQuestionStatusRecordService;
import org.jeecg.modules.golf.question.service.IQuestionTypeMappingService;
import org.jeecg.modules.golf.tag.service.ITagMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiguansheng
 * @date 2020/11/8
 **/
@Api(tags="问题分析")
@RestController
@RequestMapping("/question/analysis")
@Slf4j
public class QuestionAnalysisController {


    @Autowired
    private IQuestionStatusRecordService questionStatusRecordService;

    @Autowired
    private IQuestionTypeMappingService questionTypeMappingService;

    @Autowired
    private ITagMappingService tagMappingService;

    @Autowired
    private IMyQuestionPlanService questionPlanService;


    /**
     * 问题状态
     * @param statisticsQuestionAnalysisQueryDTO
     * @return
     */
    @GetMapping("status")
    public Result<StatisticsQuestionStatusDTO> statisticStatus(StatisticsQuestionAnalysisQueryDTO statisticsQuestionAnalysisQueryDTO){

        return Result.OK(questionStatusRecordService.statisticStatus(statisticsQuestionAnalysisQueryDTO));
    }

    /**
     * 问题分类
     * @param statisticsQuestionAnalysisQueryDTO
     * @return
     */
    @GetMapping("type")
    public Result<Page<QuestionTypeAnalysisDTO>> typeDistAnalysis(StatisticsQuestionAnalysisQueryDTO statisticsQuestionAnalysisQueryDTO){
        Page<QuestionTypeAnalysisDTO > page = new Page<>(1,100);
        page.setRecords(questionTypeMappingService.typeDistAnalysis(statisticsQuestionAnalysisQueryDTO));
       return Result.OK( page);
    }

    /**
     * 适用学员的分析页面
     * 适用问题分析
     *
     *
     * 问题标签分布
     * @param statisticsQuestionAnalysisQueryDTO
     * @return
     */
    @GetMapping("tag")
    public Result<Page<QuestionTagAnalysisDTO>> tagAnalysis(StatisticsQuestionAnalysisQueryDTO statisticsQuestionAnalysisQueryDTO){
        return Result.OK(tagMappingService.tagAnalysis(statisticsQuestionAnalysisQueryDTO));
    }


    /**
     * 训练分析
     * @param questionQueryPageDTO
     * @return
     */
    @GetMapping("train")
    public Result<IPage<TrainAnalysisDTO>> trainAnalysis( QuestionQueryPageDTO<TrainAnalysisDTO> questionQueryPageDTO){
        return Result.OK(questionPlanService.trainAnalysis(questionQueryPageDTO));

   }
    /**
     * 方案分析
     * @param myPlanAnalysisQueryDTO
     * @return
     */
    @GetMapping("plan")
    public Result<IPage<MyPlanAnalysisDTO>> trainAnalysis(MyPlanAnalysisQueryDTO myPlanAnalysisQueryDTO){
        return Result.OK(questionPlanService.planAnalysis(myPlanAnalysisQueryDTO));

   }

}
